package com.whzm.config;

import org.springframework.amqp.AmqpException;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessagePostProcessor;

//工具类，注入过期时间
public class ExpiraionMessagePostProcessor implements MessagePostProcessor {
   //创建过期时间，私有属性
    private String ttl;
    //创建一个构造方法
    public ExpiraionMessagePostProcessor(String ttl){
        this.ttl=ttl;
    }
    //重写父类的构造方法，将自己的过期时间注入
    @Override
    public Message postProcessMessage(Message message) throws AmqpException {
       message.getMessageProperties().setExpiration(ttl);
        return message;
    }


}
